package net.learn.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.learn.framework.common.page.PageResult;
import net.learn.framework.common.service.impl.BaseServiceImpl;
import net.learn.system.convert.SysVideoDetailConvert;
import net.learn.system.convert.SysVideoResultConvert;
import net.learn.system.dao.SysVideoResultDao;
import net.learn.system.entity.SysVideoDetailEntity;
import net.learn.system.entity.SysVideoResultEntity;
import net.learn.system.query.SysVideoDetailQuery;
import net.learn.system.query.SysVideoResultQuery;
import net.learn.system.service.SysVideoResultService;
import net.learn.system.utils.UUIDUtil;
import net.learn.system.vo.SysVideoDetailVO;
import net.learn.system.vo.SysVideoResultVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 *
 * @author 李立志
 * @since 2022-01-11
 */
@Service
public class SysVideoResultServiceImpl extends BaseServiceImpl<SysVideoResultDao, SysVideoResultEntity> implements SysVideoResultService {

    @Override
    public Boolean addVideoResult(SysVideoResultVO vo){
        SysVideoResultEntity entity = SysVideoResultConvert.INSTANCE.convert(vo);
        String uuid= UUIDUtil.uuid();
        entity.setUid(uuid);
        return baseMapper.insert(entity)>0;
    }
    @Override
    public Boolean updateVideoResult(SysVideoResultVO vo){
        SysVideoResultEntity entity = SysVideoResultConvert.INSTANCE.convert(vo);
        return baseMapper.updateById(entity) > 0;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(List<Long> idList) {

        removeByIds(idList);
    }
    @Override
    public List<SysVideoResultVO> qryVideoResultList(SysVideoResultQuery qry) {

        return baseMapper.qryVideoResultList(qry);
    }
    @Override
    public PageResult<SysVideoResultVO> qryVideoResultListPage(SysVideoResultQuery query) {
        IPage<SysVideoResultEntity> page = baseMapper.qryVideoResultListPage(getPage(query), query);

        return new PageResult<>(SysVideoResultConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
    }
}
